"use strict";
function _defineProperty(e, n, t) {
    return n in e ? Object.defineProperty(e, n, {
        value: t,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[n] = t,
    e
}
function _toConsumableArray(e) {
    if (Array.isArray(e)) {
        for (var n = 0,
        t = Array(e.length); n < e.length; n++) t[n] = e[n];
        return t
    }
    return Array.from(e)
}
var _slicedToArray = function() {
    function e(e, n) {
        var t = [],
        r = !0,
        o = !1,
        a = void 0;
        try {
            for (var i, c = e[Symbol.iterator](); ! (r = (i = c.next()).done) && (t.push(i.value), !n || t.length !== n); r = !0);
        } catch(e) {
            o = !0,
            a = e
        } finally {
            try { ! r && c.
                return && c.
                return ()
            } finally {
                if (o) throw a
            }
        }
        return t
    }
    return function(n, t) {
        if (Array.isArray(n)) return n;
        if (Symbol.iterator in Object(n)) return e(n, t);
        throw new TypeError("Invalid attempt to destructure non-iterable instance")
    }
} (),
_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
function(e) {
    return typeof e
}: function(e) {
    return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol": typeof e
}; !
function(e) {
    e.factory("api", ["$http", "$timeout", "$filter", "loginUrl",
    function(e, n, t, r) {
        var o = {},
        a = {};
        o.SimplePromise = function(e) {
            var t = null,
            r = null,
            o = [],
            a = this,
            i = null,
            c = function e(n) {
                if (n === a) throw "promise should not be resolve by itself";
                if (("object" === (void 0 === n ? "undefined": _typeof(n)) || "function" == typeof n) && n && "then" in n && "function" == typeof n.then) {
                    i = !0;
                    try {
                        n.then(e, l)
                    } catch(e) {
                        l(e)
                    }
                } else t = !0,
                r = n,
                setTimeout(u, 0)
            },
            l = function(e) {
                t = !1,
                r = e,
                setTimeout(u, 0)
            };
            try {
                e(function(e) {
                    null === t && null === i && c(e)
                },
                function(e) {
                    null === t && null === i && l(e)
                })
            } catch(e) {
                if (null !== t || null !== i) return;
                t = !1,
                r = e,
                setTimeout(u, 0)
            }
            e = null;
            var u = function() {
                if (null !== t) for (; o.length;) !
                function() {
                    var e = o.shift(),
                    a = e.onFullfilled,
                    i = e.onRejected,
                    c = e.resolve,
                    l = e.reject,
                    u = t ? a: i;
                    u && "function" == typeof u ? n(function() {
                        try {
                            c(u(r))
                        } catch(e) {
                            l(e)
                        }
                    }) : (t ? c: l)(r)
                } ()
            },
            s = function(e, n, t, r) {
                o.push({
                    onFullfilled: e,
                    onRejected: n,
                    resolve: t,
                    reject: r
                }),
                setTimeout(u, 0)
            };
            Object.defineProperty(this, "promise", {
                enumerable: !1,
                configurable: !1,
                writable: !1,
                value: s
            })
        },
        o.SimplePromise.prototype.then = function(e, n) {
            var t = this;
            return new o.SimplePromise(function(r, o) {
                t.promise(e, n, r, o)
            })
        },
        o.SimplePromise.prototype.
        catch = function(e) {
            var n = this;
            return new o.SimplePromise(function(t, r) {
                n.promise(void 0, e, t, r)
            })
        },
        o.SimplePromise.all = function(e) {
            return new o.SimplePromise(function(n, t) {
                var r = [],
                o = 0;
                try { [].concat(_toConsumableArray(e)).forEach(function(a, i) {
                        a.then(function(t) {
                            r[i] = t,
                            ++o === e.length && n(r)
                        }).
                        catch(function(e) {
                            t(e)
                        })
                    })
                } catch(e) {
                    t(e)
                }
            })
        },
        o.SimplePromise.race = function(e) {
            return new o.SimplePromise(function(n, t) {
                try { [].concat(_toConsumableArray(e)).forEach(function(e) {
                        return e.then(n).
                        catch(t)
                    })
                } catch(e) {
                    t(e)
                }
            })
        },
        o.SimplePromise.reject = function(e) {
            return new o.SimplePromise(function(n, t) {
                t(e)
            })
        },
        o.SimplePromise.resolve = function(e) {
            return new o.SimplePromise(function(n, t) {
                n(e)
            })
        },
        o.loadScript = function() {
            var e = Object.create({}),
            n = function(e, n, t) {
                return n && n() ? o.SimplePromise.resolve(!0) : new o.SimplePromise(function(r, a) {
                    var i = function() {
                        r(!n || n())
                    },
                    c = document.createElement("script");
                    c.src = e,
                    c.type = "text/javascript",
                    c.addEventListener("load",
                    function() {
                        "function" == typeof t ? o.SimplePromise.resolve(t()).then(i) : i()
                    }),
                    (document.body || document.getElementsByTagName("head")[0]).appendChild(c)
                })
            };
            return function(t, r, o) {
                return e.hasOwnProperty(t) || (e[t] = n(t, r, o)),
                e[t]
            }
        } ();
        var i = function(n, t, r) {
            return function(i) {
                for (var c = arguments.length,
                l = Array(c > 1 ? c - 1 : 0), u = 1; u < c; u++) l[u - 1] = arguments[u];
                return new o.SimplePromise(function(o, c) {
                    var u, s = (u = angular).merge.apply(u, [{},
                    {
                        method: n,
                        url: t
                    },
                    r, {
                        data: i
                    }].concat(l));
                    console.log("[NETWORK][REQUEST] %s %s\n%o", s.method, s.url, s);
                    var p = function(e) {
                        try {
                            var n = e.status >= 200 && e.status < 300,
                            t = e.data;
                            if (401 === e.status) return void(location.href = "/login/login.html");
                            var r = null,
                            i = null;
                            if (n && ("string" == typeof t ? r = t: t instanceof ArrayBuffer ? r = t: "object" === (void 0 === t ? "undefined": _typeof(t)) ? 200 === t.resultCode ? r = t.result: (n = !1, i = t.resultMsg) : n = !1), n) console.log("[NETWORK][RESPONSE] %s %s\n%o", s.method, s.url, r),
                            o(r);
                            else {
                                var l = i || "请求处理时发生错误";
                                l in a && (l = a[l]),
                                console.warn("[NETWORK][FAIL] %s %s\n%o", s.method, s.url, l);
                                var u = new Error(l);
                                u.response = e,
                                c(u)
                            }
                        } catch(e) {
                            console.warn("[NETWORK][EXCEPTION] %s %s\n%o", s.method, s.url, e),
                            c(new Error(""))
                        }
                    };
                    e(s).then(p, p)
                })
            }
        },
        c = function(e) {
            return function() {
                var n = void 0,
                t = void 0,
                r = !0;
                try {
                    n = e.apply(void 0, arguments)
                } catch(e) {
                    t = e,
                    r = !1
                }
                return r ? o.SimplePromise.resolve(angular.copy(n)) : o.SimplePromise.reject(angular.copy(t))
            }
        },
        l = function(e) {
            return function() {
                return e
            }
        };
        return o.network = function(e) {
            var n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "GET",
            t = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : void 0;
            return i(n, e, t)()
        },
        o.global = function() {
            var e = {};
            return e.isInMemoryDatabase = function() {
                return i("GET", "/api/global/database")().then(function(e) {
                    return "H2" === e
                })
            },
            e
        } (),
        o.memberCollection = function() {
            var e = {};
            return e.addOne = function(e, n) {
                return i("POST", "/api/collection_members/single")({
                    collectionId: e.id,
                    resourceType: e.type,
                    userId: n.id,
                    role: n.role
                })
            },
            e.addMany = function(e, n) {
                return i("POST", "/api/collection_members/multiple")({
                    collectionId: e.id,
                    resourceType: e.type,
                    members: (n || []).map(function(e) {
                        return {
                            userId: e.id,
                            role: e.role
                        }
                    })
                })
            },
            e.add = function(e, n) {
                return angular.isArray(n) ? o.memberCollection.addMany(e, n) : o.memberCollection.addOne(e, n)
            },
            e.modify = function(e, n) {
                return i("PUT", "/api/collection_members/single")({
                    collectionId: e.id,
                    resourceType: e.type,
                    userId: n.id,
                    role: n.role
                })
            },
            e.delete = function(e, n) {
                return i("DELETE", "/api/collection_members/" + e.id + "/" + n.id + "/" + e.type)()
            },
            e.get = function(e) {
                return i("GET", "/api/collection_members/" + e.id + "/" + e.type)().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            id: e.userId,
                            role: e.role,
                            name: e.username
                        }
                    })
                })
            },
            e.getTypes = c(l(["PROJECT_COLLECTION", "DEPLOY_COLLECTION", "CLUSTER", "CONFIGURATION_COLLECTION", "LOADBALANCER_COLLECTION"])),
            e.listByType = function(e) {
                return i("GET", "/api/collections/" + e)().then(function(n) {
                    return (n || []).map(function(n) {
                        return {
                            id: n.id,
                            type: e,
                            name: n.name,
                            description: n.description
                        }
                    })
                })
            },
            e.myRole = function(e) {
                return o.user.myRole(e)
            },
            e
        } (),
        o.user = function() {
            var e = {},
            n = function(e) {
                return {
                    id: e.id,
                    name: e.username,
                    email: e.email,
                    phone: e.phone,
                    loginType: e.loginType,
                    createTime: new Date(1e3 * e.createTime),
                    isAdmin: "adminPrivilege" in e ? !!e.adminPrivilege: null
                }
            };
            return e.whoami = function(e) {
                return i("GET", "/api/user/get", {
                    cache: !e
                })().then(n)
            },
            e.passwd = function(n) {
                var t = n.name,
                r = n.oldPassword,
                o = n.newPassword;
                return e.whoami().then(function(e) {
                    return e.isAdmin ? i("POST", "/api/user/adminChangePassword")({
                        username: t,
                        password: o
                    }).
                    catch(function(e) {
                        throw ""
                    }) : i("POST", "/api/user/changePassword")({
                        username: t,
                        oldpassword: r,
                        newpassword: o
                    }).
                    catch(function(e) {
                        if (("" + e).indexOf("password wrong") !== -1) throw "原密码不正确";
                        if (("" + e).indexOf("username wrong") !== -1) throw "用户名不正确";
                        throw ""
                    })
                })
            },
            e.modify = function(e) {
                var n = e.id,
                t = e.name,
                r = e.email,
                o = e.phone;
                return i("POST", "/api/user/modify")({
                    id: n,
                    phone: o,
                    email: r,
                    username: t
                })
            },
            e.list = function() {
                return i("GET", "/api/user/list")().then(function(e) {
                    return (e || []).map(n)
                })
            },
            e.myRole = function(e) {
                return i("GET", "/api/user/resource/" + e.type + "/" + e.id)()
            },
            e.logout = function() {
                return i("GET", "/api/user/logout")().
                catch(function(e) {
                    if (e.response.status !== -1) throw e
                })
            },
            e
        } (),
        o.image = function() {
            var e = {};
            return e.public = function() {
                var e = {};
                return e.list = function() {
                    return i("GET", "/api/image/public/catalog")().then(function(e) {
                        return (e || []).map(function(e) {
                            return {
                                name: e.imageName,
                                tagList: Array(e.size),
                                downloadCount: e.downloadCount,
                                icon: e.iconUrl,
                                updateTime: new Date(e.lastModified)
                            }
                        })
                    })
                },
                e.detail = function(e) {
                    return i("GET", "/api/image/public/image?imageName=" + e.name)().then(function(e) {
                        return {
                            name: e.imageName,
                            tagList: (e.tagInfos || []).map(function(e) {
                                return {
                                    image: e.imageName,
                                    name: e.imageTag,
                                    size: e.imageSize,
                                    downloadCount: e.downloadCount,
                                    createTime: new Date(e.createTime),
                                    dockerfileUrl: e.dockerfileUrl,
                                    imageUrl: e.imageUrl
                                }
                            }),
                            downloadCount: e.downloadCount,
                            icon: e.iconUrl,
                            createTime: new Date(e.createTime),
                            updateTime: new Date(e.lastModified),
                            readmeUrl: e.readMeUrl,
                            description: e.description
                        }
                    })
                },
                e
            } (),
            e.privateRegistry = function() {
                var e = {};
                return e.list = function() {
                    return i("GET", "/api/image")().then(function(e) {
                        return (e || []).map(function(e) {
                            return {
                                id: e.projectId,
                                name: e.imageName,
                                registry: e.registry,
                                tag: e.tag,
                                envSettings: e.envSettings,
                                createTime: new Date(e.createTime)
                            }
                        })
                    })
                },
                e.listImageTags = function(e, n) {
                    return i("GET", "/api/image/detail?name=" + e + "&registry=" + n)()
                },
                e
            } (),
            e
        } (),
        o.deployment = function() {
            var e = {};
            return e.collection = function() {
                return i("GET", "/api/deploycollection")().then(function(e) {
                    return e.map(function(e) {
                        return {
                            id: e.id,
                            name: e.name,
                            description: e.description,
                            creator: {
                                id: e.creatorId,
                                name: e.creatorName
                            },
                            createTime: new Date(e.createTime),
                            memberCount: e.memberCount,
                            deployCount: e.deployCount,
                            role: e.role
                        }
                    })
                })
            },
            e.listInCollection = function(e) {
                return i("GET", "/api/deploy/list/${collection.id}").then(function(e) {
                    return e.map(function(e) {
                        return {
                            id: e.deployId,
                            name: e.deployName,
                            createTime: new Date(e.createTime),
                            lastUpdateTime: new Date(e.lastUpdateTime),
                            status: e.deploymentStatus,
                            cluster: {
                                name: e.clusterName
                            },
                            namespace: e.namespace,
                            hostEnv: e.hostEnv,
                            replicas: e.replicas,
                            monitor: {
                                cpu: {
                                    total: e.cpuTotal,
                                    using: e.cpuUsed
                                },
                                memory: {
                                    total: e.memoryTotal,
                                    using: e.memoryUsed
                                }
                            },
                            serviceDnsName: e.serviceDnsName,
                            mayDelete: e.deletable
                        }
                    })
                })
            },
            e.list = function() {
                return i("GET", "/api/deploy/list")()
            },
            e.delete = function(e) {
                return i("DELETE", "/api/deploy/id/" + e)()
            },
            e.get = function(e) {
                return i("GET", "/api/deploy/id/" + e)().then(function(e) {
                    return {
                        deployId: e.deployId,
                        deployName: e.deployName,
                        clusterId: e.clusterId,
                        clusterName: e.clusterName,
                        clusterLog: e.clusterLog,
                        lastUpdateTime: e.lastUpdateTime,
                        deploymentStatus: e.deploymentStatus,
                        currentReplicas: e.currentReplicas,
                        defaultReplicas: e.defaultReplicas,
                        namespace: e.namespace,
                        currentVersions: (e.currentVersions || []).map(function(e) {
                            return e.labelSelectors = (e.labelSelectors || []).filter(function(e) {
                                return "USER_LABEL_VALUE" === e.content
                            }),
                            e.containerConsoles = (e.containerConsoles || []).map(function(e) {
                                return {
                                    registry: e.registry,
                                    name: e.image,
                                    tag: e.tag,
                                    cpu: e.cpu,
                                    mem: e.mem,
                                    oldEnv: [],
                                    newEnv: e.envs,
                                    oldLabel: [],
                                    newLabel: e.customLabels,
                                    healthChecker: e.healthChecker,
                                    readinessChecker: e.readinessChecker,
                                    logItemDrafts: e.logItemDrafts,
                                    imagePullPolicy: e.imagePullPolicy,
                                    autoDeploy: e.autoDeploy,
                                    volumeMountConsoles: e.volumeMountConsoles.map(function(e) {
                                        return e.readonly = e.readonly.toString(),
                                        e
                                    }),
                                    configConsoles: e.configConsoles,
                                    commands: (e.commands || [])[0] || "",
                                    args: e.args || []
                                }
                            }),
                            e
                        }),
                        healthChecker: e.healthChecker,
                        lbForDeploys: e.lbForDeploys,
                        scalable: e.scalable,
                        stateful: e.stateful,
                        serviceDnsName: e.serviceDnsName,
                        accessType: e.accessType,
                        exposePortNum: e.exposePortNum,
                        networkMode: e.networkMode,
                        versionType: e.versionType,
                        deletable: e.deletable,
                        deploymentType: e.deploymentType,
                        deployTypeShow: e.deployTypeShow,
                        description: e.description
                    }
                })
            },
            e.create = function(e) {
                return i("POST", "/api/deploy/create")({
                    creatorId: e.creatorId,
                    collectionId: e.collectionId,
                    deployName: e.name,
                    description: e.description,
                    versionType: e.versionType,
                    deploymentType: e.deploymentType,
                    replicas: e.replicas,
                    clusterId: e.cluster.id,
                    namespace: e.namespace.namespace,
                    hostEnv: e.hostEnv,
                    networkMode: e.networkMode,
                    labelSelectors: function() {
                        var n = {
                            TEST: "TESTENV",
                            PROD: "PRODENV"
                        };
                        return (e.labelSelectors || []).filter(function(e) {
                            return "HOSTENVTYPE" !== e.content
                        }).concat({
                            name: n[e.hostEnv],
                            content: "HOSTENVTYPE"
                        })
                    } (),
                    loadBalancerDraft: function() {
                        var n = {};
                        return "internal" === e.visitMode ? (n.sessionAffinity = e.loadBalanceDraft.sessionAffinity, n.type = "INNER_SERVICE", n.loadBalancerPorts = e.loadBalanceDraft.loadBalancerPorts.map(function(e) {
                            return {
                                port: e.targetPort,
                                targetPort: e.targetPort,
                                protocol: "TCP"
                            }
                        })) : n = null,
                        n
                    } (),
                    accessType: function() {
                        return "HOST" === e.networkMode ? "DIY": "noAccess" === e.visitMode ? "DIY": (e.visitMode, "K8S_SERVICE")
                    } (),
                    exposePortNum: e.exposePortNum ? e.exposePortNum: 0,
                    podSpecStr: ["YAML", "JSON"].includes(e.versionType) ? e.versionString.podSpecStr || "": "",
                    containerConsoles: "CUSTOM" === e.versionType ? e.containerConsoles.map(function(e) {
                        return {
                            registry: e.registry,
                            image: e.name,
                            tag: e.tag,
                            cpu: e.cpu,
                            mem: e.mem,
                            envs: (e.oldEnv || []).concat(e.newEnv),
                            customLabels: (e.oldLabel || []).concat(e.newLabel),
                            healthChecker: e.healthChecker,
                            readinessChecker: e.readinessChecker,
                            logItemDrafts: e.logItemDrafts,
                            imagePullPolicy: e.imagePullPolicy,
                            autoDeploy: e.autoDeploy,
                            volumeMountConsoles: function() {
                                return (e.volumeMountConsoles || []).map(function(e) {
                                    return e
                                })
                            } (),
                            configConsoles: function() {
                                return (e.configConsoles || []).map(function(e) {
                                    return e.name = e.configMap.name,
                                    e.volumeConfigMap.configurationId = e.configMap.id,
                                    e.volumeConfigMap.name = e.configMap.name,
                                    e.volumeConfigMap.iterms = e.configMap.configFileList.reduce(function(e, n) {
                                        return n.path && (e[n.name] = n.path),
                                        e
                                    },
                                    {}),
                                    e.configMap = void 0,
                                    e
                                })
                            } (),
                            commands: [e.commands].filter(function(e) {
                                return e
                            }),
                            args: (e.args || []).filter(function(e) {
                                return e
                            })
                        }
                    }) : []
                }).then(function() {
                    if (e.namespace && e.namespace.namespace && !e.namespace.isExistentNamespace) {
                        var n = [e.namespace.namespace];
                        o.cluster.setNamespace(e.cluster.id, n)
                    }
                })
            },
            e.updateDescription = function(e, n) {
                return i("PUT", "/api/deploy/id/" + e + "/description")(n)
            },
            e.getDeploymentStr = function(e) {
                return i("POST", "/api/deploy/deploymentstr")({
                    deployName: e.name,
                    collectionId: e.collectionId,
                    replicas: e.replicas,
                    deploymentType: e.deploymentType,
                    versionType: e.versionType,
                    hostEnv: e.hostEnv,
                    clusterId: e.cluster.id,
                    namespace: e.namespace.namespace,
                    labelSelectors: e.labelSelectors,
                    networkMode: e.networkMode
                })
            },
            e.getEvents = function(e) {
                return i("GET", "/api/deploy/event/list?deployId=" + e)()
            },
            e.getInstances = function(e) {
                return i("GET", "/api/deploy/" + e + "/instance")()
            },
            e.getDeployLoadBalance = function(e) {
                return i("GET", "/api/deploy/id/" + e + "/loadbalancer")()
            },
            e.updateLoadBalance = function(e, n) {
                return i("PUT", "/api/deploy/id/" + e + "/loadbalancer")({
                    sessionAffinity: n.sessionAffinity,
                    loadBalancerPorts: (n.loadBalancerPorts || []).map(function(e) {
                        return {
                            port: e.targetPort,
                            targetPort: e.targetPort,
                            protocol: "TCP"
                        }
                    })
                })
            },
            e.version = function() {
                var e = {};
                return e.listVersion = function(e) {
                    return i("GET", "/api/version/list?deployId=" + e)()
                },
                e.getVersionById = function(e, n) {
                    return i("GET", "/api/version/id/" + e + "/" + n)().then(function(e) {
                        return {
                            deployId: e.deployId,
                            id: e.id,
                            description: e.description,
                            labelSelectors: (e.labelSelectors || []).filter(function(e) {
                                return "USER_LABEL_VALUE" === e.content
                            }),
                            hostList: e.hostList,
                            versionType: e.versionType,
                            podSpecStr: e.podSpecStr,
                            version: e.version,
                            createTime: e.createTime,
                            deprecate: e.deprecate,
                            containerConsoles: (e.containerConsoles || []).map(function(e) {
                                return {
                                    registry: e.registry,
                                    name: e.image,
                                    tag: e.tag,
                                    cpu: e.cpu,
                                    mem: e.mem,
                                    oldEnv: [],
                                    newEnv: e.envs,
                                    oldLabel: [],
                                    newLabel: e.customLabels,
                                    healthChecker: e.healthChecker,
                                    readinessChecker: e.readinessChecker,
                                    logItemDrafts: e.logItemDrafts,
                                    imagePullPolicy: e.imagePullPolicy,
                                    autoDeploy: e.autoDeploy,
                                    volumeMountConsoles: e.volumeMountConsoles.map(function(e) {
                                        return e.readonly = e.readonly.toString(),
                                        e
                                    }),
                                    configConsoles: e.configConsoles,
                                    commands: (e.commands || [])[0] || "",
                                    args: e.args || []
                                }
                            }),
                            clusterName: e.clusterName,
                            hostEnv: e.hostEnv,
                            networkMode: e.networkMode,
                            versionString: e.versionString
                        }
                    })
                },
                e.createVersion = function(e, n) {
                    return i("POST", "/api/version/create?deployId=" + e)({
                        deployId: n.deployId,
                        labelSelectors: function() {
                            var e = {
                                TEST: {
                                    name: "TESTENV",
                                    content: "HOSTENVTYPE"
                                },
                                PROD: {
                                    name: "PRODENV",
                                    content: "HOSTENVTYPE"
                                }
                            };
                            return n.labelSelectors = n.labelSelectors.filter(function(e) {
                                return "HOSTENVTYPE" !== e.content
                            }).concat(e[n.hostEnv]),
                            n.labelSelectors
                        } (),
                        hostList: n.hostList,
                        versionType: n.versionType,
                        podSpecStr: ["YAML", "JSON"].includes(n.versionType) ? n.versionString.podSpecStr || "": "",
                        version: n.version,
                        deprecate: n.deprecate,
                        containerConsoles: "CUSTOM" === n.versionType ? n.containerConsoles.map(function(e) {
                            return {
                                registry: e.registry,
                                image: e.name,
                                tag: e.tag,
                                cpu: e.cpu,
                                mem: e.mem,
                                envs: (e.oldEnv || []).concat(e.newEnv),
                                customLabels: (e.oldLabel || []).concat(e.newLabel),
                                healthChecker: e.healthChecker,
                                readinessChecker: e.readinessChecker,
                                logItemDrafts: e.logItemDrafts,
                                imagePullPolicy: e.imagePullPolicy,
                                autoDeploy: e.autoDeploy,
                                commands: [e.commands].filter(function(e) {
                                    return e
                                }),
                                args: (e.args || []).filter(function(e) {
                                    return e
                                }),
                                volumeMountConsoles: function() {
                                    return (e.volumeMountConsoles || []).map(function(e) {
                                        return e
                                    })
                                } (),
                                configConsoles: function() {
                                    return (e.configConsoles || []).map(function(e) {
                                        return e.name = e.configMap.name,
                                        e.volumeConfigMap.configurationId = e.configMap.id,
                                        e.volumeConfigMap.name = e.configMap.name,
                                        e.volumeConfigMap.iterms = e.configMap.configFileList.reduce(function(e, n) {
                                            return n.path && (e[n.name] = n.path),
                                            e
                                        },
                                        {}),
                                        e
                                    })
                                } ()
                            }
                        }) : []
                    })
                },
                e.deprecateVersion = function(e, n) {
                    return i("DELETE", "/api/version/" + e + "/" + n + "/deprecate")()
                },
                e.recoverDeprecateVersion = function(e, n) {
                    return i("PUT", "/api/version/" + e + "/" + n + "/enable")()
                },
                e
            } (),
            e.action = function() {
                var e = {},
                n = "/api/deploy/action";
                return e.updateDeployment = function(e, t, r) {
                    return i("POST", n + "/update?deployId=" + e + "&version=" + t + "&replicas=" + r)()
                },
                e.stop = function(e) {
                    return i("POST", n + "/stop?deployId=" + e.id)()
                },
                e.abort = function(e) {
                    return i("POST", n + "/abort?deployId=" + e.id)()
                },
                e.rollback = function(e) {
                    return i("POST", "/api/deploy/action/rollback?deployId=" + e.id + "&version=" + e.version + (e.replicas ? "&replicas=" + e.replicas: ""))()
                },
                e.update = function(e) {
                    return i("POST", "/api/deploy/action/" + (e.currentVersion > e.version ? "rollback": "update") + "?deployId=" + e.id + "&version=" + e.version + (e.replicas ? "&replicas=" + e.replicas: ""))().then(function(n) {
                        return {
                            response: n,
                            tip: "已提交，正在" + (e.currentVersion > e.version ? "回滚": "升级") + "。"
                        }
                    })
                },
                e.start = function(e) {
                    return i("POST", "/api/deploy/action/start?deployId=" + e.id + "&version=" + e.version + (e.replicas ? "&replicas=" + e.replicas: ""))()
                },
                e.scale = function(e) {
                    return e.labels.length ? i("POST", "/api/deploy/action/daemonset/scales?deployId=" + e.id + "&version=" + e.currentVersion)(e.labels).then(function(e) {
                        return {
                            response: e,
                            tip: "操作成功"
                        }
                    }) : i("POST", "/api/deploy/action/" + (e.replicas > e.currentReplicas ? "scaleup": "scaledown") + "/?deployId=" + e.id + "&version=" + e.currentVersion + "&replicas=" + e.replicas)().then(function(n) {
                        return {
                            response: n,
                            tip: "已提交，正在" + (e.replicas > e.currentReplicas ? "扩容": "缩容") + "。"
                        }
                    })
                },
                e.restart = function(e) {
                    return i("DELETE", "/api/deploy/" + e.id + "/instance?instanceName=" + e.instanceName)()
                },
                e
            } (),
            e
        } (),
        o.cluster = function() {
            var e = {},
            n = "/api/cluster";
            return e.getClusterById = function(e) {
                return i("GET", n + "/" + e)().then(function(e) {
                    return {
                        id: e.id,
                        name: e.name,
                        logConfig: e.logConfig,
                        api: e.api,
                        tag: e.tag,
                        ownerName: e.ownerName,
                        role: e.role,
                        domain: e.domain,
                        createTime: e.createTime,
                        clusterMonitor: e.clusterMonitor,
                        nodeNum: e.nodeNum,
                        podNum: e.podNum,
                        buildConfig: e.buildConfig
                    }
                })
            },
            e.listCluster = function() {
                return i("GET", n)().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            id: e.id,
                            name: e.name,
                            logConfig: e.logConfig,
                            api: e.api,
                            tag: e.tag,
                            ownerName: e.ownerName,
                            role: e.role,
                            domain: e.domain,
                            createTime: e.createTime,
                            clusterMonitor: e.clusterMonitor,
                            nodeNum: e.nodeNum,
                            podNum: e.podNum,
                            buildConfig: e.buildConfig
                        }
                    })
                })
            },
            e.getNamespace = function(e) {
                return i("GET", n + "/" + e + "/namespace")()
            },
            e.setNamespace = function(e, t) {
                return i("POST", n + "/" + e + "/namespace")(t)
            },
            e.listNodeList = function(e) {
                return i("GET", n + "/" + e + "/nodelist")().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            name: e.name,
                            ip: e.ip,
                            status: e.status,
                            runningPods: e.runningPods,
                            capacity: e.capacity,
                            disk: e.disk,
                            createTime: e.createTime,
                            labels: e.labels,
                            dockerVersion: e.dockerVersion,
                            kubeletVersion: e.kubeletVersion,
                            kernelVersion: e.kernelVersion,
                            osVersion: e.osVersion
                        }
                    })
                })
            },
            e.listHostLabel = function(e) {
                return i("GET", n + "/" + e + "/labels")().then(function(e) {
                    return Object.keys(e || {}).map(function(n) {
                        return {
                            name: n,
                            content: e[n]
                        }
                    })
                })
            },
            e.listNodeByLabels = function(e, t) {
                var r = (t || []).reduce(function(e, n) {
                    return e[n.name] = n.content,
                    e
                },
                {}),
                o = encodeURI(JSON.stringify(r));
                return i("GET", n + "/" + e + "/nodelistwithlabels?labels=" + o)().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            name: e.name,
                            ip: e.ip,
                            status: e.status,
                            runningPods: e.runningPods,
                            capacity: e.capacity,
                            disk: e.disk,
                            createTime: e.createTime,
                            labels: e.labels,
                            dockerVersion: e.dockerVersion,
                            kubeletVersion: e.kubeletVersion,
                            kernelVersion: e.kernelVersion,
                            osVersion: e.osVersion
                        }
                    })
                })
            },
            e.hasNodeByLabels = function(n, t) {
                return e.listNodeByLabels(n, t).then(function(e) {
                    return !! e.length
                })
            },
            e.listInstance = function(e) {
                return i("GET", "/api/cluster/" + e + "/instancelist")().then(function(e) {
                    return (e || []).map(function(e) {
                        return e
                    })
                })
            },
            e.listInstanceByLabel = function(e, n) {
                var t = Object.assign.apply(Object, [{}].concat(_toConsumableArray((n || []).map(function(e) {
                    return _defineProperty({},
                    e.name, e.content)
                })))),
                r = encodeURI(JSON.stringify(t));
                return i("GET", "/api/cluster/" + e + "/instancelistwithlabels?labels=" + r)().then(function(e) {
                    return (e || []).map(function(e) {
                        return e
                    })
                })
            },
            e.addNodeLabels = function(e, n) {
                return i("POST", "/api/cluster/" + e + "/nodelabels/add")((n || []).map(function(e) {
                    return {
                        node: e.nodeName,
                        labels: e.labels
                    }
                }))
            },
            e.deleteNodeLabels = function(e, n) {
                return i("POST", "/api/cluster/" + e + "/nodelabels/delete")((n || []).map(function(e) {
                    return {
                        node: e.nodeName,
                        labels: e.labels
                    }
                }))
            },
            e
        } (),
        o.configMap = function() {
            var e = {},
            n = "/api/configurationcollection";
            return e.listConfigMapCollection = function() {
                return i("GET", n)().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            id: e.id,
                            name: e.name,
                            description: e.description,
                            createTime: e.createTime,
                            role: e.role,
                            configMapCount: e.configurationCount,
                            memberCount: e.memberCount,
                            creatorInfo: e.creatorInfo
                        }
                    })
                })
            },
            e.createConfigMapCollection = function(e) {
                return i("POST", n)({
                    name: e.name,
                    description: e.description
                })
            },
            e.getConfigMapCollectionById = function(e) {
                return i("GET", n + "/" + e)().then(function(e) {
                    return {
                        id: e.configurationCollection.id,
                        name: e.configurationCollection.name,
                        description: e.configurationCollection.description,
                        createTime: e.configurationCollection.createTime,
                        creatorId: e.creatorInfo.creatorId,
                        creatorName: e.creatorInfo.name
                    }
                })
            },
            e.deleteConfigMapCollection = function(e) {
                return i("DELETE", n + "/" + e)()
            },
            e.updateConfigMapCollection = function(e) {
                return i("PUT", n)(e)
            },
            e.listConfigMap = function(e) {
                return i("GET", n + "/" + e + "/configuration")().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            id: e.configuration.id,
                            name: e.configuration.name,
                            description: e.configuration.description,
                            clusterId: e.configuration.clusterId,
                            namespace: e.configuration.namespace,
                            labelSelectors: e.configuration.labelSelectors,
                            data: e.configuration.data,
                            configFileList: Object.keys(e.configuration.data || {}).map(function(n) {
                                return {
                                    name: n,
                                    content: e.configuration.data[n]
                                }
                            }),
                            createTime: e.configuration.createTime,
                            creatorInfo: e.creatorInfo,
                            creator: e.creatorInfo.name,
                            clusterName: e.clusterName,
                            collectionId: e.collectionId
                        }
                    })
                })
            },
            e.listConfigMapAll = function() {
                return i("GET", n + "/configuration")().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            id: e.configuration.id,
                            name: e.configuration.name,
                            description: e.configuration.description,
                            clusterId: e.configuration.clusterId,
                            namespace: e.configuration.namespace,
                            labelSelectors: e.configuration.labelSelectors,
                            data: e.configuration.data,
                            configFileList: Object.keys(e.configuration.data || {}).map(function(n) {
                                return {
                                    name: n,
                                    content: e.configuration.data[n]
                                }
                            }),
                            createTime: e.configuration.createTime,
                            creatorInfo: e.creatorInfo,
                            creator: e.creatorInfo.name,
                            clusterName: e.clusterName,
                            collectionId: e.collectionId
                        }
                    })
                })
            },
            e.listConfigMapByClusterId = function(e) {
                return i("GET", n + "/cluster/" + e + "/configuration")().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            id: e.configuration.id,
                            name: e.configuration.name,
                            description: e.configuration.description,
                            clusterId: e.configuration.clusterId,
                            namespace: e.configuration.namespace,
                            labelSelectors: e.configuration.labelSelectors,
                            data: e.configuration.data,
                            configFileList: Object.keys(e.configuration.data || {}).map(function(n) {
                                return {
                                    name: n,
                                    content: e.configuration.data[n]
                                }
                            }),
                            createTime: e.configuration.createTime,
                            creatorInfo: e.creatorInfo,
                            creator: e.creatorInfo.name,
                            clusterName: e.clusterName,
                            collectionId: e.collectionId
                        }
                    })
                })
            },
            e.listConfigMapByClusterIdAndNamespace = function(e, t) {
                return i("GET", n + "/cluster/" + e + "/" + t + "/configuration")().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            id: e.configuration.id,
                            name: e.configuration.name,
                            description: e.configuration.description,
                            clusterId: e.configuration.clusterId,
                            namespace: e.configuration.namespace,
                            labelSelectors: e.configuration.labelSelectors,
                            data: e.configuration.data,
                            configFileList: Object.keys(e.configuration.data || {}).map(function(n) {
                                return {
                                    name: n,
                                    content: e.configuration.data[n]
                                }
                            }),
                            createTime: e.configuration.createTime,
                            creatorInfo: e.creatorInfo,
                            creator: e.creatorInfo.name,
                            clusterName: e.clusterName,
                            collectionId: e.collectionId
                        }
                    })
                })
            },
            e.createConfigMap = function(e, t) {
                return i("POST", n + "/" + e + "/configuration")({
                    name: t.name,
                    description: t.description,
                    clusterId: t.clusterId,
                    namespace: t.namespace,
                    data: t.configFileList.reduce(function(e, n) {
                        return e[n.name] = n.content,
                        e
                    },
                    {})
                })
            },
            e.getConfigMap = function(e) {
                return i("GET", n + "/configuration/" + e)().then(function(e) {
                    return {
                        id: e.configuration.id,
                        name: e.configuration.name,
                        description: e.configuration.description,
                        clusterId: e.configuration.clusterId,
                        namespace: e.configuration.namespace,
                        labelSelectors: e.configuration.labelSelectors,
                        configFileList: Object.keys(e.configuration.data || {}).map(function(n) {
                            return {
                                name: n,
                                content: e.configuration.data[n]
                            }
                        }),
                        data: e.configuration.data,
                        createTime: e.configuration.createTime,
                        creatorInfo: e.creatorInfo,
                        creator: e.creatorInfo.name,
                        clusterName: e.clusterName,
                        collectionId: e.collectionId
                    }
                })
            },
            e.deleteConfigMap = function(e) {
                return i("DELETE", n + "/configuration/" + e)()
            },
            e.updateConfigMap = function(e, t) {
                return i("PUT", n + "/" + e + "/configuration")({
                    id: t.id,
                    name: t.name,
                    description: t.description,
                    clusterId: t.clusterId,
                    namespace: t.namespace,
                    labelSelectors: t.labelSelectors,
                    createTime: t.createTime,
                    data: t.configFileList.reduce(function(e, n) {
                        return e[n.name] = n.content,
                        e
                    },
                    {})
                })
            },
            e.listRelatedDeploy = function(e) {
                return i("GET", n + "/configuration/" + e + "/deployinfo")()
            },
            e
        } (),
        o.overview = function() {
            var e = {};
            e.usage = function() {
                return i("GET", "/api/overview/usage")().then(function(e) {
                    return {
                        project: {
                            collection: e.projectCollection || 0,
                            total: e.project || 0
                        },
                        deploy: {
                            collection: e.deployCollection || 0,
                            total: e.deployment || 0
                        },
                        image: {
                            total: e.image || 0,
                            base: e.imageBase || 0,
                            project: e.imageProject || 0,
                            other: e.imageOther || 0
                        },
                        cluster: {
                            total: e.cluster || 0
                        },
                        storage: {
                            total: e.storage || 0
                        },
                        volume: {
                            total: e.volume || 0,
                            using: e.volumeUsing || 0
                        },
                        config: {
                            collection: e.configurationCollection || 0,
                            total: e.configuration || 0
                        },
                        loadBalance: {
                            total: e.loadBalancerCollection,
                            nginx: e.loadBalancerNginx,
                            kubeProxy: e.loadBalancerProxy
                        }
                    }
                })
            },
            e.resource = function() {
                return i("GET", "/api/overview/resource")().then(function(e) {
                    return {
                        memory: {
                            total: e.memoryTotal,
                            using: e.memoryUsed,
                            free: e.memoryTotal - e.memoryUsed
                        },
                        cpu: {
                            total: e.cpu0To25 + e.cpu25To50 + e.cpu50To75 + e.cpu75To100,
                            load_0_25: e.cpu0To25,
                            load_25_50: e.cpu25To50,
                            load_50_75: e.cpu50To75,
                            load_75_100: e.cpu75To100
                        },
                        node: {
                            total: e.node,
                            online: e.nodeOnline,
                            offline: e.nodeOffline
                        }
                    }
                })
            },
            e.disk = function() {
                return i("GET", "/api/overview/disk")().then(function(e) {
                    return {
                        disk: {
                            total: e.diskTotal,
                            using: e.diskTotal - e.diskRemain,
                            free: e.diskRemain
                        }
                    }
                })
            };
            var n = function(e, n, t) {
                var r = {
                    PROJECT_COLLECTION: "项目$",
                    PROJECT: "工程$",
                    DEPLOY_COLLECTION: "服务$",
                    DEPLOY: "部署$",
                    STORAGE_CLUSTER: "存储$",
                    CONFIGURATION: "配置$",
                    CONFIGURATION_COLLECTION: "配置集合$",
                    CLUSTER: "集群$",
                    LOADBALANCER: "负载均衡实例$",
                    LOADBALANCER_COLLECTION: "负载均衡$"
                },
                o = {
                    SET: "添加$",
                    MODIFY: "修改$",
                    DELETE: "删除$",
                    BUILD: "构建$",
                    SCALEUP: "扩容$",
                    SCALEDOWN: "缩容$",
                    START: "启动$",
                    STOP: "停止$",
                    UPDATE: "升级$",
                    ROLLBACK: "回滚$",
                    ABORT: "中断$",
                    DELETEINSTANCE: "重启$实例"
                };
                if (r.hasOwnProperty(n) && o.hasOwnProperty(t)) return o[t].replace(/\$/,
                function() {
                    return r[n].replace(/\$/,
                    function() {
                        return e
                    })
                })
            };
            e.actionList = function() {
                return i("GET", "/api/overview/operation")().then(function(e) {
                    var t = [],
                    r = !0,
                    o = !1,
                    a = void 0;
                    try {
                        for (var i, c = e[Symbol.iterator](); ! (r = (i = c.next()).done); r = !0) {
                            var l = i.value,
                            u = n(l.resourceName, l.resourceType, l.operation);
                            u.length && t.push({
                                target: l.resourceName,
                                targetType: l.resourceType,
                                verb: l.operation,
                                user: {
                                    id: l.userId,
                                    name: l.userName
                                },
                                time: new Date(l.operateTime),
                                text: u
                            })
                        }
                    } catch(e) {
                        o = !0,
                        a = e
                    } finally {
                        try { ! r && c.
                            return && c.
                            return ()
                        } finally {
                            if (o) throw a
                        }
                    }
                    return {
                        actionList: t
                    }
                })
            };
            var t = function(e, n, t, r) {
                return {
                    cpu_percent: "CPU使用率 <#> <r>%，为 <l>%",
                    memory_percent: "内存使用率 <#> <r>%，为 <l>%",
                    disk_percent: "磁盘使用率 <#> <r>%，为 <l>%",
                    disk_read: "磁盘读取速率 <#> <r>KB/s，为 <l>KB/s",
                    disk_write: "磁盘写入速率 <#> <r>KB/s，为 <l>KB/s",
                    network_in: "网络流入速率 <#> <r>KB/s，为 <l>KB/s",
                    network_out: "网络流出速率 <#> <r>KB/s，为 <l>KB/s",
                    agent_alive: "监控代理未处于活动状态"
                } [e].replace(/<#>/,
                function() {
                    return {
                        "==": "等于",
                        "!=": "不等于",
                        "<": "小于",
                        "<=": "小于等于",
                        ">": "大于",
                        ">=": "大于等于"
                    } [n]
                }).replace(/<l>/,
                function() {
                    return (r + "").slice(0, 4).replace(/\.$/, "")
                }).replace(/<r>/,
                function() {
                    return (t + "").slice(0, 4).replace(/\.$/, "")
                })
            };
            return e.alarmList = function() {
                return i("GET", "/api/alarm/event")().then(function(e) {
                    return {
                        alarmList: e.map(function(e) {
                            return {
                                time: new Date(e.timeStamp),
                                text: t(e.metric, e.operator, e.rightValue, e.leftValue)
                            }
                        })
                    }
                },
                function() {
                    return {
                        alarmList: null
                    }
                })
            },
            e.project = function() {
                return i("GET", "/api/overview/project")().then(function(e) {
                    return {
                        action: {
                            build: {
                                auto: e.autoBuild,
                                manual: e.manualBuild
                            }
                        }
                    }
                })
            },
            e.deployment = function() {
                return i("GET", "/api/overview/deployment")().then(function(e) {
                    return {
                        action: {
                            deploy: {
                                auto: e.autoDeploy,
                                online: e.onlineNumber,
                                online_detail: (e.onlineDetails || []).map(function(e) {
                                    return {
                                        start: e.startNumber,
                                        update: e.updateNumber,
                                        rollback: e.rollbackNumber,
                                        scale_up: e.scaleUpNumber,
                                        scale_down: e.scaleDownNumber
                                    }
                                })
                            }
                        }
                    }
                })
            },
            e.id = function() {
                return i("GET", "/api/global/uuid")().then(function(e) {
                    return {
                        id: e
                    }
                })
            },
            e.version = function() {
                return i("GET", "/api/global/version")().then(function(e) {
                    return {
                        version: e
                    }
                })
            },
            e
        } (),
        o.globleConfig = function() {
            var e = {};
            return e.hasGitProject = function(e) {
                return i("GET", "/api/global/gitconfig/" + e + "/usage")().then(function(e) {
                    return e && e.length
                })
            },
            e
        } (),
        o.globalSetting = function() {
            var e = {};
            return e.login = function() {
                var e = {};
                return e.getLdapConfig = function() {
                    return i("GET", "/api/global/ldapconfig")().then(function(e) {
                        return {
                            enabled: !0,
                            server: e.server,
                            suffix: e.emailSuffix
                        }
                    }).
                    catch(function(e) {
                        return {
                            enabled: !1
                        }
                    })
                },
                e.getSsoConfig = function() {
                    return i("GET", "/api/global/ssoconfig")().then(function(e) {
                        return {
                            enabled: !0,
                            server: e.casServerUrl,
                            login: e.loginUrl,
                            logout: e.logoutUrl
                        }
                    }).
                    catch(function(e) {
                        return {
                            enabled: !1
                        }
                    })
                },
                e.getConfig = function() {
                    return o.SimplePromise.all([e.getLdapConfig(), e.getSsoConfig()]).then(function(e) {
                        var n = _slicedToArray(e, 2);
                        return {
                            ldapConfig: n[0],
                            ssoConfig: n[1]
                        }
                    })
                },
                e.putLdapConfig = function(e) {
                    return e.enabled ? i("POST", "/api/global/ldapconfig")({
                        server: e.server,
                        emailSuffix: e.suffix
                    }) : i("DELETE", "/api/global/ldapconfig")()
                },
                e.putSsoConfig = function(e) {
                    return e.enabled ? i("POST", "/api/global/ssoconfig")({
                        casServerUrl: e.server,
                        loginUrl: e.login,
                        logoutUrl: e.logout
                    }) : i("DELETE", "/api/global/ssoconfig")()
                },
                e.putConfig = function(n) {
                    var t = n.ldapConfig,
                    r = n.ssoConfig;
                    return o.SimplePromise.all([e.putLdapConfig(t), e.putSsoConfig(r)])
                },
                e
            } (),
            e
        } (),
        o.select = function() {
            var e = {},
            n = function(e) {
                var n = e.text,
                t = e.remark,
                r = e.value,
                o = e.match;
                return "string" == typeof n && (n = function(e) {
                    return function(n) {
                        return n[e]
                    }
                } (n)),
                void 0 === t && (t = function() {
                    return ""
                }),
                "string" == typeof t && (t = function(e) {
                    return function(n) {
                        return n[e]
                    }
                } (t)),
                void 0 === r && (r = function(e) {
                    return e
                }),
                void 0 === o && (o = ["id"]),
                "string" == typeof o && (o = [o]),
                Array.isArray(o) && (o = function(e) {
                    return function(n) {
                        return Object.assign.apply(Object, [{}].concat(_toConsumableArray(e.map(function(e) {
                            return e in n ? _defineProperty({},
                            e, n[e]) : {}
                        }))))
                    }
                } (o)),
                function(e) {
                    return e.map(function(e) {
                        return {
                            text: n(e),
                            remark: t(e),
                            value: r(e),
                            match: o(e)
                        }
                    })
                }
            },
            r = function(e, n) {
                return function(t) {
                    return (t && e(t) ? n: c(l([])))(t)
                }
            };
            return e.deployCollectionList = function() {
                return i("GET", "/api/deploycollection")().then(function(e) {
                    return e.map(function(e) {
                        return {
                            id: e.id,
                            name: e.name
                        }
                    })
                }).then(n({
                    text: "name"
                }))
            },
            e.deployListByCollection = r(function(e) {
                return "id" in e
            },
            function(e) {
                return i("GET", "/api/deploy/list/" + e.id)().then(function(n) {
                    return n.filter(function(e) {
                        return "CUSTOM" === e.versionType
                    }).map(function(n) {
                        return {
                            id: n.deployId,
                            name: n.deployName,
                            collection: e
                        }
                    })
                }).then(n({
                    text: "name"
                }))
            }),
            e.deployVersionList = r(function(e) {
                return "id" in e
            },
            function(e) {
                return i("GET", "/api/version/list?deployId=" + e.id)().then(function(n) {
                    return n.map(function(n) {
                        return {
                            id: n.version,
                            deploy: e
                        }
                    })
                }).then(n({
                    text: function(e) {
                        return "version" + e.id
                    }
                }))
            }),
            e.imageVersionList = r(function(e) {
                return "name" in e && "registry" in e
            },
            function(e) {
                return i("GET", "/api/image/detail?name=" + e.name + "&registry=" + e.registry)().then(function(e) {
                    return e.map(function(e) {
                        return {
                            name: e.tag,
                            createTime: e.createTime
                        }
                    })
                }).then(n({
                    text: "name",
                    remark: function(e) {
                        return t("time")(e.createTime)
                    },
                    value: function(e) {
                        return e.name
                    }
                }))
            }),
            e
        } (),
        o.loadBalance = function() {
            var e = {};
            return e.collection = function() {
                var e = {};
                return e.list = function() {
                    return i("GET", "/api/loadBalancerCollection/list")().then(function(e) {
                        return (e || []).map(function(e) {
                            return {
                                id: e.id,
                                name: e.name,
                                description: e.description,
                                creatorName: e.creatorName,
                                creatorId: e.creatorId,
                                createTime: e.createTime,
                                type: e.lbcType,
                                loadBalancerCount: e.loadBalancerCount,
                                memberCount: e.memberCount,
                                role: e.role
                            }
                        })
                    })
                },
                e.getById = function(e) {
                    return i("GET", "/api/loadBalancerCollection/" + e)().then(function(e) {
                        return {
                            id: e.id,
                            name: e.name,
                            description: e.description,
                            creatorName: e.creatorName,
                            creatorId: e.creatorId,
                            createTime: e.createTime,
                            type: e.lbcType,
                            role: e.role
                        }
                    })
                },
                e.create = function(e) {
                    return i("POST", "/api/loadBalancerCollection")({
                        name: e.name,
                        description: e.description,
                        type: e.type
                    })
                },
                e.update = function(e) {
                    return i("PUT", "/api/loadBalancerCollection")({
                        id: e.id,
                        name: e.name,
                        description: e.description,
                        type: e.type
                    })
                },
                e.delete = function(e) {
                    return i("DELETE", "/api/loadBalancerCollection/" + e)()
                },
                e
            } (),
            e.loadBalance = function() {
                var e = {};
                return e.create = function(e) {
                    return i("POST", "/api/loadBalancer")({
                        lbcId: e.collectionId,
                        name: e.name,
                        description: e.description,
                        type: e.type,
                        clusterId: e.cluster.id,
                        namespace: e.namespace.namespace,
                        externalIPs: "EXTERNAL_SERVICE" === e.type ? e.externalIPs: (e.nginxDraft.nodeDraft || []).map(function(e) {
                            return e.ip
                        }),
                        serviceDraft: function() {
                            var n = {};
                            return "EXTERNAL_SERVICE" === e.type ? (n.lbPorts = e.serviceDraft.lbPorts, n.sessionAffinity = e.serviceDraft.sessionAffinity, n.deployId = e.serviceDraft.deployment.deployId, n.deployName = e.serviceDraft.deployment.deployName, n.deployStatus = e.serviceDraft.deployment.deployStatus) : n = null,
                            n
                        } (),
                        nginxDraft: function() {
                            var n = {};
                            return "NGINX" === e.type ? (n.listenPort = e.nginxDraft.listenPort, n.registry = e.nginxDraft.registry, n.image = e.nginxDraft.image, n.tag = e.nginxDraft.tag, n.lbMethod = e.nginxDraft.lbMethod, n.cpu = e.nginxDraft.cpu, n.mem = e.nginxDraft.mem, n.selectors = "TEST" === e.nginxDraft.hostEnv ? [{
                                name: "TESTENV",
                                content: "HOSTENVTYPE"
                            }] : [{
                                name: "PRODENV",
                                content: "HOSTENVTYPE"
                            }], n.volumeConsole = function() {
                                return "EMPTYDIR" === e.nginxDraft.volumeConsole.volumeType ? null: "HOSTPATH" === e.nginxDraft.volumeConsole.volumeType ? {
                                    readonly: !1,
                                    hostPath: e.nginxDraft.volumeConsole.hostPath,
                                    volumeType: e.nginxDraft.volumeConsole.volumeType
                                }: null
                            } (), n.rules = e.nginxDraft.rules && 0 !== e.nginxDraft.rules.length ? e.nginxDraft.rules.map(function(e) {
                                return {
                                    domain: e.domain,
                                    deployId: e.deployment.deployId,
                                    deployName: e.deployment.deployName,
                                    deployStatus: e.deployment.deployStatus,
                                    serviceName: e.deployment.innerServiceName,
                                    servicePort: e.servicePort
                                }
                            }) : null) : n = null,
                            n
                        } ()
                    }).then(function() {
                        if ("NGINX" === e.type && e.namespace && e.namespace.namespace && !e.namespace.isExistentNamespace) {
                            var n = [e.namespace.namespace];
                            o.cluster.setNamespace(e.cluster.id, n)
                        }
                    })
                },
                e.listAll = function() {
                    return i("GET", "/api/loadBalancer/list")().then(function(e) {
                        return (e || []).filter(function(e) {
                            return "NGINX" === e.type
                        }).map(function(e) {
                            return {
                                deployId: e.id,
                                deployName: e.name,
                                type: e.type,
                                clusterName: e.clusterName,
                                namespace: e.namespace,
                                lastUpdateTime: e.lastUpdateTime,
                                createTime: e.createTime,
                                dnsName: e.dnsName,
                                state: e.state,
                                deletable: e.deletable,
                                cpuTotal: e.cpuTotal,
                                cpuUsed: e.cpuUsed,
                                memoryTotal: e.memoryTotal,
                                memoryUsed: e.memoryUsed,
                                hostEnv: (e.selectors || []).some(function(e) {
                                    return "PRODENV" === e.name
                                }) ? "PROD": "TEST"
                            }
                        })
                    })
                },
                e.list = function(e) {
                    return i("GET", "/api/loadBalancer/list/" + e)().then(function(e) {
                        return (e || []).map(function(e) {
                            return {
                                id: e.id,
                                name: e.name,
                                type: e.type,
                                clusterName: e.clusterName,
                                namespace: e.namespace,
                                lastUpdateTime: e.lastUpdateTime,
                                createTime: e.createTime,
                                dnsName: e.dnsName,
                                state: e.state,
                                deletable: e.deletable,
                                cpuTotal: e.cpuTotal,
                                cpuUsed: e.cpuUsed,
                                memoryTotal: e.memoryTotal,
                                memoryUsed: e.memoryUsed,
                                resourcePercent: function() {
                                    var n = e.cpuTotal ? Math.max(0, e.cpuUsed / e.cpuTotal) : 0,
                                    t = e.memoryTotal ? Math.max(0, e.memoryUsed / e.memoryTotal) : 0;
                                    return n > t ? {
                                        value: "cpu",
                                        text: "CPU",
                                        cpuTotal: e.cpuTotal,
                                        cpuUsed: e.cpuUsed,
                                        percent: n
                                    }: {
                                        value: "memory",
                                        text: "内存",
                                        memoryTotal: e.memoryTotal,
                                        memoryUsed: e.memoryUsed,
                                        percent: t
                                    }
                                } ()
                            }
                        })
                    })
                },
                e.listDeployment = function(e, n, t) {
                    return i("GET", "/api/loadBalancer/deploy/list?clusterId=" + e + "&namespace=" + n + "&lbType=" + t)()
                },
                e.getById = function(e) {
                    return i("GET", "/api/loadBalancer/id/" + e)().then(function(e) {
                        return e.nginxDraft ? (e.nginxDraft.rules = (e.nginxDraft.rules || []).map(function(e) {
                            return {
                                domain: e.domain,
                                deployId: e.deployId,
                                deployName: e.deployName,
                                deployStatus: e.deployStatus,
                                serviceName: e.serviceName,
                                servicePort: e.servicePort,
                                deployment: {
                                    deployId: e.deployId,
                                    deployName: e.deployName,
                                    deployStatus: e.deployStatus
                                }
                            }
                        }), e.nginxDraft.currentVersions && (e.nginxDraft.currentVersions = e.nginxDraft.currentVersions.map(function(e) {
                            return e.nodeDraft = (e.externalIPs || []).map(function(e) {
                                return {
                                    ip: e
                                }
                            }),
                            e.hostEnv = (e.selectors || []).some(function(e) {
                                return "PRODENV" === e.name
                            }) ? "PROD": "TEST",
                            e.volumeDraft = e.volumeDraft ? e.volumeDraft: {
                                volumeType: "EMPTYDIR"
                            },
                            e
                        }))) : e.serviceDraft && (e.serviceDraft.deployment = {
                            deployId: e.serviceDraft.deployId,
                            deployName: e.serviceDraft.deployName,
                            deployStatus: e.serviceDraft.deployStatus
                        },
                        e.serviceDraft.sessionAffinity = String(e.serviceDraft.sessionAffinity)),
                        e
                    })
                },
                e.delete = function(e) {
                    return i("DELETE", "/api/loadBalancer/id/" + e)()
                },
                e.update = function(e) {
                    return i("PUT", "/api/loadBalancer")({
                        lbcId: e.lbcId,
                        id: e.id,
                        name: e.name,
                        description: e.description,
                        type: e.type,
                        clusterId: e.clusterId,
                        namespace: e.namespace,
                        externalIPs: e.externalIPs,
                        serviceDraft: function() {
                            var n = {};
                            return "EXTERNAL_SERVICE" === e.type ? (n.lbPorts = e.serviceDraft.lbPorts, n.sessionAffinity = e.serviceDraft.sessionAffinity, n.deployId = e.serviceDraft.deployment.deployId, n.deployName = e.serviceDraft.deployment.deployName, n.deployStatus = e.serviceDraft.deployment.deployStatus) : n = null,
                            n
                        } (),
                        nginxDraft: function() {
                            var n = {};
                            return "NGINX" === e.type ? n.rules = (e.nginxDraft.rules || []).map(function(e) {
                                return {
                                    domain: e.domain,
                                    deployId: e.deployment.deployId,
                                    deployName: e.deployment.deployName,
                                    deployStatus: e.deployment.deployStatus,
                                    serviceName: e.deployment.innerServiceName,
                                    servicePort: e.servicePort
                                }
                            }) : n = null,
                            n
                        } ()
                    })
                },
                e.listInstance = function(e) {
                    return i("GET", "/api/loadBalancer/instance/list/" + e)()
                },
                e.restartInstance = function(e, n) {
                    return i("DELETE", "/api/loadBalancer/instance/" + e + "?instanceName=" + n)()
                },
                e.updateDescription = function(e, n) {
                    return i("PUT", "/api/loadBalancer/id/" + e + "/description")(n)
                },
                e.listEvent = function(e) {
                    return i("GET", "/api/loadBalancer/event/list/" + e)()
                },
                e
            } (),
            e.version = function() {
                var e = {};
                return e.listVersion = function(e) {
                    return i("GET", "/api/loadBalancer/version/list/" + e)()
                },
                e.getVersionById = function(e, n) {
                    return i("GET", "/api/loadBalancer/version/id/" + e + "/" + n)().then(function(e) {
                        return e.nodeDraft = (e.externalIPs || []).map(function(e) {
                            return {
                                ip: e
                            }
                        }),
                        e.hostEnv = (e.selectors || []).some(function(e) {
                            return "PRODENV" === e.name
                        }) ? "PROD": "TEST",
                        e.volumeDraft = e.volumeDraft ? e.volumeDraft: {
                            volumeType: "EMPTYDIR"
                        },
                        e
                    })
                },
                e.create = function(e, n) {
                    return i("POST", "/api/loadBalancer/version/" + e)({
                        listenPort: n.listenPort,
                        externalIPs: (n.nodeDraft || []).map(function(e) {
                            return e.ip
                        }).filter(function(e) {
                            return null != e
                        }),
                        registry: n.registry,
                        image: n.image,
                        tag: n.tag,
                        lbMethod: n.lbMethod,
                        cpu: n.cpu,
                        mem: n.mem,
                        deployIdForLB: n.deployIdForLB,
                        selectors: "TEST" === n.hostEnv ? [{
                            name: "TESTENV",
                            content: "HOSTENVTYPE"
                        }] : [{
                            name: "PRODENV",
                            content: "HOSTENVTYPE"
                        }],
                        volumeDraft: function() {
                            return "EMPTYDIR" === n.volumeDraft.volumeType ? null: "HOSTPATH" === n.volumeDraft.volumeType ? {
                                readonly: !1,
                                hostPath: n.volumeDraft.hostPath,
                                volumeType: n.volumeDraft.volumeType
                            }: null
                        } ()
                    })
                },
                e
            } (),
            e.action = function() {
                var e = {};
                return e.rollback = function(e, n) {
                    return i("POST", "/api/loadBalancer/action/rollback/" + e + "/" + n)()
                },
                e.scale = function(e, n, t) {
                    return i("POST", "/api/loadBalancer/action/scales/" + e + "/" + n)(t)
                },
                e.start = function(e, n) {
                    return i("POST", "/api/loadBalancer/action/start/" + e + "/" + n)()
                },
                e.stop = function(e) {
                    return i("POST", "/api/loadBalancer/action/stop/" + e)()
                },
                e.update = function(e, n) {
                    return i("POST", "/api/loadBalancer/action/update/" + e + "/" + n)()
                },
                e
            } (),
            e
        } (),
        o.listItem = function() {
            var e = {};
            return e.nodeByLabels = function(e) {
                var n = [],
                t = {
                    TEST: {
                        name: "TESTENV",
                        content: "HOSTENVTYPE"
                    },
                    PROD: {
                        name: "PRODENV",
                        content: "HOSTENVTYPE"
                    }
                };
                n = n.filter(function(e) {
                    return "HOSTENVTYPE" !== e.content
                }).concat(t[e.hostEnv]);
                var r = (n || []).reduce(function(e, n) {
                    return e[n.name] = n.content,
                    e
                },
                {}),
                o = encodeURIComponent(JSON.stringify(r));
                return i("GET", "/api/cluster/" + e.clusterId + "/nodelistwithlabels?labels=" + o)().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            value: {
                                name: e.name,
                                ip: e.ip,
                                status: e.status,
                                runningPodsCount: e.runningPods,
                                capacity: e.capacity,
                                disk: e.disk,
                                createTime: e.createTime,
                                labels: e.labels
                            },
                            text: e.ip,
                            remark: "名称：" + e.name + " 状态：" + e.status,
                            match: {
                                ip: e.ip
                            }
                        }
                    }).filter(function(e) {
                        return "Ready" === e.value.status
                    })
                })
            },
            e.loadBalanceDeployment = function(e) {
                return i("GET", "/api/loadBalancer/deploy/list?clusterId=" + e.clusterId + "&namespace=" + e.namespace + "&lbType=" + e.loadBalanceType)().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            value: e,
                            text: e.deployName,
                            match: {
                                deployName: e.deployName
                            }
                        }
                    })
                })
            },
            e.storageByClusterIdAndNamespace = function(e) {
                return i("GET", "/api/storage/cluster/" + e.clusterId + "/" + e.namespace + "/volume")().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            value: {
                                id: e.storageVolumeDraft.id,
                                name: e.storageVolumeDraft.name,
                                description: e.storageVolumeDraft.description,
                                clusterId: e.storageVolumeDraft.clusterId,
                                clusterName: e.storageVolumeDraft.clusterName,
                                namespace: e.storageVolumeDraft.namespace,
                                labels: e.storageVolumeDraft.labels,
                                capacity: e.storageVolumeDraft.capacity,
                                accessMode: e.storageVolumeDraft.accessMode,
                                readOnly: e.storageVolumeDraft.readOnly,
                                reclaimPolicy: e.storageVolumeDraft.reclaimPolicy,
                                glusterfsDraft: e.storageVolumeDraft.glusterfsDraft,
                                cephfsDraft: e.storageVolumeDraft.cephfsDraft,
                                rbdDraft: e.storageVolumeDraft.rbdDraft,
                                creatorInfo: e.creatorInfo,
                                status: e.status,
                                storageType: e.storageVolumeDraft.storageType
                            },
                            text: e.storageVolumeDraft.name,
                            remark: "状态：" + e.status + "/类型：" + e.storageVolumeDraft.storageType,
                            match: {
                                name: e.storageVolumeDraft.name
                            }
                        }
                    })
                })
            },
            e.foreignServiceIPByClusterId = function(e) {
                return i("GET", "/api/cluster/" + e.clusterId + "/nodelist")().then(function(e) {
                    return (e || []).map(function(e) {
                        return {
                            value: e.ip,
                            text: e.ip,
                            remark: "主机：" + e.name + " 状态：" + e.status,
                            match: e.ip
                        }
                    })
                })
            },
            e
        } (),
        o
    }]),
    e.factory("userFriendlyMessage", [function() {
        var e = [{
            pattern: /^.*FORBIDDEN.*$/,
            message: "抱歉，您没有权限操作该项目。"
        }];
        return function(n) {
            return e.forEach(function(e) {
                n = n.replace(e.pattern, e.message)
            }),
            n
        }
    }])
} (angular.module("backendApi", ["constant"]));